package com.wy.panda.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wy.panda.common.page.PageResult;
import com.wy.panda.common.util.StringUtils;
import com.wy.panda.dao.criteria.SysUserCriteria;
import com.wy.panda.dao.mapper.SysUserMapper;
import com.wy.panda.entity.SysUserEntity;
import com.wy.panda.service.SysUserService;

/**
 * 用户
 *
 * @author wangyuan
 * @date 2021-03-27 13:27:02
 */
@Service("sysUserService")
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity> implements SysUserService {
    
    @Override
    public PageResult<SysUserEntity> listPage(SysUserCriteria criteria) {
        IPage<SysUserEntity> page = criteria.page();
        
        LambdaQueryWrapper<SysUserEntity> queryWrapper = Wrappers.lambdaQuery();
        
        queryWrapper.like(StringUtils.isNotBlank(criteria.getUsername()), SysUserEntity::getUsername, criteria.getUsername());
        
        page = page(page, queryWrapper);
        
        return PageResult.build(page);
    }
}